package com.ruoyi.project.module.prodiuuctname.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.prodiuuctname.domain.Prodiuuctname;
import com.ruoyi.project.module.prodiuuctname.service.IProdiuuctnameService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 商品 信息操作处理
 * 
 * @author ruoyi
 * @date 2018-11-13
 */
@Controller
@RequestMapping("/module/prodiuuctname")
public class ProdiuuctnameController extends BaseController
{
    private String prefix = "module/prodiuuctname";
	
	@Autowired
	private IProdiuuctnameService prodiuuctnameService;
	
	@RequiresPermissions("module:prodiuuctname:view")
	@GetMapping()
	public String prodiuuctname()
	{
	    return prefix + "/prodiuuctname";
	}
	
	/**
	 * 查询商品列表
	 */
	@RequiresPermissions("module:prodiuuctname:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Prodiuuctname prodiuuctname)
	{
		startPage();
        List<Prodiuuctname> list = prodiuuctnameService.selectProdiuuctnameList(prodiuuctname);
		return getDataTable(list);
	}
	
	/**
	 * 新增商品
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存商品
	 */
	@RequiresPermissions("module:prodiuuctname:add")
	@Log(title = "商品", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Prodiuuctname prodiuuctname)
	{		
		return toAjax(prodiuuctnameService.insertProdiuuctname(prodiuuctname));
	}

	/**
	 * 修改商品
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		Prodiuuctname prodiuuctname = prodiuuctnameService.selectProdiuuctnameById(id);
		mmap.put("prodiuuctname", prodiuuctname);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存商品
	 */
	@RequiresPermissions("module:prodiuuctname:edit")
	@Log(title = "商品", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Prodiuuctname prodiuuctname)
	{		
		return toAjax(prodiuuctnameService.updateProdiuuctname(prodiuuctname));
	}
	
	/**
	 * 删除商品
	 */
	@RequiresPermissions("module:prodiuuctname:remove")
	@Log(title = "商品", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(prodiuuctnameService.deleteProdiuuctnameByIds(ids));
	}
	
}
